// 所有接口
import ask from "./config";

let baseApiUrl
let wy_baseApiUrl
console.log("process.env", process.env)
if (process.env.NODE_ENV === "development") {
  // 开发环境 不需要填基础路径
  baseApiUrl = ""
  wy_baseApiUrl = ""
  let reg = /dev/
  if (reg.test(window.location.href)) {
    // 线上测试服
    baseApiUrl = "http://dev.2217admin.tonnn.com/"
    wy_baseApiUrl = "http://devmob.admin.tonnn.com/"
  }
} else {
  baseApiUrl = "http://2217admin.tonnn.com/"
  wy_baseApiUrl = "http://mob.admin.tonnn.com/"
}

export default {
  //登录
  login (params) {
    return ask.askPost(baseApiUrl + "api/login", params)
  },
  //登录记住token
  roleLogin (params) {
    return ask.askPost(wy_baseApiUrl + "admin/role/login", params)
  },
  //退出
  logout () {
    return ask.askPost(baseApiUrl + "api/logout")
  },
  // 上传
  fyUpload (id, name, params) {
    return ask.askPost(baseApiUrl + `api/m/regpage/syncfiles/${name}/${id}`, params)
  },
  //2020 首页接口开始
  //首页获取平台目标
  platformGoal (params) {
    return ask.askPost(baseApiUrl + "api/g/platform/goal/", params)
  },
  //首页设置目标
  setGoal (params) {
    return ask.askPost(baseApiUrl + "api/g/platform/goal/set", params)
  },
  //首页获取平台流水
  platformIncome (params) {
    return ask.askPost(baseApiUrl + "api/g/platform/income/", params)
  },
  //首页获取游戏数据
  wyGameReport (params) {
    return ask.askGet(wy_baseApiUrl + "admin/data/index/game/daily", params)
  },
  webGameReport (params) {
    return ask.askPost(baseApiUrl + "api/g/platform/game/data/", params)
  },
  //首页获取渠道数据
  wyChannelData (params) {
    return ask.askGet(wy_baseApiUrl + "admin/data/index/channel/daily", params)
  },
  webChannelData (params) {
    return ask.askPost(baseApiUrl + "api/g/platform/channel/data/", params)
  },
  //最近上线项目
  onlineProjectData (params) {
    return ask.askGet(baseApiUrl + "api/weiyou/report/module/4", params)
  },
  uploadOnlineExcel (params) {
    return ask.askPost(baseApiUrl + "api/weiyou/report/module/4", params)
  },
  // -------------------------- 模块2 -------------------------------
  searchPlatFormData (params) {
    return ask.askPost(baseApiUrl + "api/g/platform/general/data/", params)
  },
  // -------------------------- 模块6 -------------------------------
  askNewAdditional (params) {
    return ask.askGet(baseApiUrl + "api/weiyou/report/module/6", params)
  },
  // -------------------------- 模块7 -------------------------------
  askIncome (params) {
    return ask.askGet(baseApiUrl + "api/weiyou/report/module/7", params)
  },

  //2020 首页接口结束
  // 市场
  //微游获取选择列表
  wyChoices (params) {
    return ask.askGet(wy_baseApiUrl + "admin/common/clearing/choices", params)
  },
  //微游渠道时段回报数据
  wyChannelHourly (params) {
    return ask.askGet(wy_baseApiUrl + "admin/channel/datas/hourly", params)
  },
  //落地页列表
  ldyList (params) {
    return ask.askGet(wy_baseApiUrl + "admin/promotion/model", params)
  },
  //落地页模版添加
  addLdy (params) {
    return ask.askPost(wy_baseApiUrl + "admin/promotion/model", params)
  },
  //落地页模版修改
  modifyLdy (params) {
    return ask.askPut(wy_baseApiUrl + "admin/promotion/model", params)
  },
  // 获取cid数据
  getCIDList (params) {
    return ask.askPost(baseApiUrl + "api/m/data/cid", params)
  },
  // 获取cid数据
  getCCIDList (params) {
    return ask.askPost(baseApiUrl + "api/m/data/ccid", params)
  },

  // -------------------------- 运营接口 -------------------------------
  // 服务器管理列表
  //  获取服务器列表
  getServerList (params) {
    return ask.askGet(wy_baseApiUrl + "admin/game/server", params)
  },
  //  添加服务器
  addServer (params) {
    return ask.askPost(wy_baseApiUrl + "admin/game/server", params)
  },
  //  编辑服务器
  editServer (params) {
    return ask.askPut(wy_baseApiUrl + "admin/game/server", params)
  },
  //  删除服务器
  deleteOpenServer (params) {
    return ask.askDelete(wy_baseApiUrl + "admin/game/server", params)
  },
  // 查询游戏的区服列表
  checkGameServerList (params) {
    return ask.askGet(wy_baseApiUrl + "admin/game/server_list/choice", params)
  },
  //  导入服务器
  importServer (params) {
    return ask.askPost(wy_baseApiUrl + "admin/game/server/import", params)
  },
  //  服务器合并列表
  gameServerMergeList (params) {
    return ask.askGet(wy_baseApiUrl + "admin/game/server/combined", params)
  },
  //  服务器合并
  newServerMerge (params) {
    return ask.askPost(wy_baseApiUrl + "admin/game/server/combined", params)
  },
  //  服务器合并
  deleteServerMerge (params) {
    return ask.askDelete(wy_baseApiUrl + "admin/game/server/combined", params)
  },
  //  导入服务器合并
  importServerMerge (params) {
    return ask.askPost(wy_baseApiUrl + "admin/game/server/combined/import", params)
  },
  // 研发列表
  // 获取研发公司列表
  getCompanyList (params) {
    return ask.askGet(wy_baseApiUrl + "admin/game/company", params)
  },
  // 新建研发公司
  newCompany (params) {
    return ask.askPost(wy_baseApiUrl + "admin/game/company", params)
  },
  // 编辑研发公司
  editCompany (params) {
    return ask.askPut(wy_baseApiUrl + "admin/game/company", params)
  },
  // 删除研发公司
  deleteCompany (params) {
    return ask.askDelete(wy_baseApiUrl + "admin/game/company", params)
  },
  // 游戏列表
  // 获取游戏列表
  getWyGameState (params) {
    return ask.askGet(wy_baseApiUrl + "admin/game", params)
  },
  // 新建游戏
  newWyGame (params) {
    return ask.askPost(wy_baseApiUrl + "admin/game", params)
  },
  // 编辑游戏
  editWyGame (params) {
    return ask.askPut(wy_baseApiUrl + "admin/game", params)
  },
  // 获取游戏选择框列表
  getWyGameSelectList (params) {
    return ask.askGet(wy_baseApiUrl + "admin/game/list/choices", params)
  },




  // -------------------------- 以下接口为上个UI下的接口（可以复用） -------------------------------


  //获取页游游戏列表
  gameList () {
    return ask.askPost(baseApiUrl + "api/g/game/list")
  },
  //获取游戏服列表
  gameServer (params) {
    return ask.askGet(baseApiUrl + "api/g/game/server", params)
  },
  //通过游戏名，服务器名称查询游戏名称
  getRoleName (params) {
    return ask.askGet(baseApiUrl + "api/g/user/user_roles", params)
  },

  // 运营
  //获取数据后台月报
  monthlyReport (params) {
    return ask.askPost(baseApiUrl + "api/o/data/game_month_report", params)
  },
  //获取游戏服报告
  gameServerReport (params) {
    return ask.askPost(baseApiUrl + "api/o/data/game_server_report", params)
  },
  //获取游戏服周期数据
  openServerReport (params) {
    return ask.askPost(baseApiUrl + "api/o/data/game_server_delta", params)
  },
  //获取游戏服数据
  gameServerTodayData (params) {
    return ask.askPost(baseApiUrl + "api/o/data/game_server", params)
  },
  // 市场
  //获取渠道数据
  channelData (params) {
    return ask.askPost(baseApiUrl + "api/m/data/channel", params)
  },
  //获取子渠道数据
  channelDetail (params) {
    return ask.askPost(baseApiUrl + "api/m/data/channel_detail", params)
  },
  //通过子渠道获取游戏数据
  channelGameDetail (params) {
    return ask.askPost(baseApiUrl + "api/m/data/channel_game_detail", params)
  },
  //导出子渠道数据
  exportChannelDetail (params) {
    return ask.askPost(baseApiUrl + "api/m/data/channel_detail/export", params)
  },
  //获取渠道列表
  channelList (params) {
    return ask.askPost(baseApiUrl + "api/m/data/channel_list", params)
  },
  //获取游戏服数据
  gameServerData (params) {
    return ask.askPost(baseApiUrl + "api/m/data/game_server", params)
  },
  //添加渠道
  addChannel (params) {
    return ask.askPost(baseApiUrl + "api/m/channel/add/", params)
  },

  // 账号操作
  //查询玩家
  findUser (params) {
    return ask.askPost(baseApiUrl + "api/g/user/query", params)
  },
  //封禁/解封玩家账号
  forbidUser (params) {
    return ask.askPost(baseApiUrl + "api/g/user/ban", params)
  },
  //封禁/解封玩家ip
  forbidIp (params) {
    return ask.askPost(baseApiUrl + "api/g/user/banip", params)
  },

  // 工单管理
  // **查询基础工单列表
  orderType (params) {
    return ask.askPost(baseApiUrl + "api/w/order/type/list", params)
  },
  // **增加基础工单列表
  addOder (params) {
    return ask.askPost(baseApiUrl + "api/w/order/type/new", params)
  },
  // **编辑基础工单列表
  editOder (params) {
    return ask.askPost(baseApiUrl + "api/w/order/type/edit", params)
  },
  // **删除基础工单列表
  deleteOder (params) {
    return ask.askPost(baseApiUrl + "api/w/order/type/del", params)
  },
  // **新建工单列表
  newOder (params) {
    return ask.askPost(baseApiUrl + "api/w/order/new", params)
  },
  // **工单列表
  oderList (params) {
    return ask.askGet(baseApiUrl + "api/w/order/list", params)
  },
  // **通过工单请求（更新状态）
  updateOder (params) {
    return ask.askPost(baseApiUrl + "api/g/order/up_state", params)
  },
  // **通过工单请求（更新用户资料）
  updateUserInfo (params) {
    return ask.askPost(baseApiUrl + "api/g/user/up/profile", params)
  },
  // **通过工单请求（平台币转移）
  updateCoinMove (params) {
    return ask.askPost(baseApiUrl + "api/g/user/coin/transfer", params)
  },
  // **通过工单请求（平台币兑换）
  updateCoinExchange (params) {
    return ask.askPost(baseApiUrl + "api/g/user/coin/exchange", params)
  },
  // **通过工单请求（短信验证码超标）
  updateVerificationCode (params) {
    return ask.askPost(baseApiUrl + "api/g/user/sms/add_times", params)
  },
  // **通过工单请求（福利中心领取）
  updateWelfareRebate (params) {
    return ask.askPost(baseApiUrl + "api/w/order/pass-welfare-rebate", params)
  },
  // **驳回工单请求（更新状态）
  unPassOder (params) {
    return ask.askPost(baseApiUrl + "api/w/order/up_state", params)
  },
  // **查询订单信息
  queryOder (params) {
    return ask.askPost(baseApiUrl + "api/g/order/query", params)
  },
  // **上传文件
  uploadFile (params,config) {
    return ask.askPost(baseApiUrl + "api/g/order/upload", params,config)
  },
  // **查询工单权限
  checkPower (params) {
    return ask.askGet(baseApiUrl + "api/g/user/permission", params)
  }
}
